home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1998 January / PC Answers Issue 49 Cover CD January 1998.iso / Apps / Director / DATA.Z / Multiple Child Objects.dir / 00002_Ancestor Ball Script.ls < prev    next >
Encoding:
Text File  |  1997-05-10  |  1.1 KB  |  40 lines

  1. property velocity, previousFlag, mySprite
  2.  
  3. on new me, listPosition
  4.   set myListPosition to listPosition
  5.   set mySprite to myListPosition + 9
  6.   puppetSound(1, "boing")
  7.   set previousFlag to 0
  8.   set velocity to 10
  9.   set the memberNum of sprite mySprite to the number of member "ball"
  10.   set the locV of sprite mySprite to 60
  11.   set the locH of sprite mySprite to random(250) + 40
  12.   return me
  13. end
  14.  
  15. on animateBall me
  16.   if not (sprite mySprite within 6) then
  17.     set flag to 0
  18.   else
  19.     set flag to 1
  20.   end if
  21.   if (flag = 1) and (previousFlag = 0) then
  22.     set velocity to velocity * -1
  23.     puppetSound(2, "bounce boing")
  24.   else
  25.     if (flag = 1) and (previousFlag = 1) then
  26.       nothing()
  27.     end if
  28.   end if
  29.   set flag to previousFlag
  30.   set currentPosition to the locV of sprite mySprite + velocity
  31.   if (currentPosition < 30) and (velocity < 0) then
  32.     set velocity to -1 * velocity
  33.     puppetSound(2, "bounce boing")
  34.   end if
  35.   if currentPosition > 270 then
  36.     set currentPosition to -30 + (currentPosition - 240)
  37.   end if
  38.   set the locV of sprite mySprite to currentPosition
  39. end
  40.